import request from "@/utils/request";


// 添加区域
export function addLocation(data: any) {
  return request<string>({
    url: "/Location/Add",
    method: "POST",
    data
  });
}

// 更新区域
export function updateLocation(data: any) {
  return request<boolean>({
    url: "/Location/Update",
    method: "PUT",
    data
  });
}

// 删除区域
export function deleteLocation(locationId: string) {
  return request<boolean>({
    url: `/Location/Delete/${locationId}`,
    method: "DELETE"
  });
}

// 获取区域详情
export function getLocationById(locationId: string) {
  return request<any>({
    url: `/Location/GetById/${locationId}`,
    method: "GET"
  });
}

// 获取所有区域
export function getLocationList() {
  return request<any[]>({
    url: "/Location/GetAll",
    method: "GET"
  });
}

// 按大区获取区域
export function getLocationsByArea(area: string) {
  return request<any[]>({
    url: `/Location/GetByArea/${area}`,
    method: "GET"
  });
}

// 更新区域大区
export function updateLocationArea(locationId: string, newArea: string) {
  return request<boolean>({
    url: `/Location/UpdateArea/${locationId}`,
    method: "POST",
    data: { newArea }
  });
}

// 搜索区域
export function searchLocations(keyword: string) {
  return request<any[]>({
    url: "/Location/Search",
    method: "GET",
    params: { keyword }
  });
}